package com.spzx.order.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.RemoteOrderInfoService;
import com.spzx.order.api.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteOrderInfoFallbackFactory implements FallbackFactory<RemoteOrderInfoService> {
    @Override
    public RemoteOrderInfoService create(Throwable throwable) {

        log.error("根据订单号获取订单信息失败 : {}", throwable.getMessage());
        return new RemoteOrderInfoService() {
            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                return R.fail("根据订单号获取订单信息失败 : " + throwable.getMessage());
            }
        };
    }
}
